<script>
	import tui from '@/common/tui'
	export default {
		onLaunch: function() {
			tt.login({
				force: false,
				success(res) {
					tui.tRawPostAction('https://developer.toutiao.com/api/apps/v2/jscode2session',{
						"appid":"ttcbe5bd5854dd728601",
						"secret":"02a5ba23866c40bdf4f5606ee593c8798c20f48e",
						"code":res.code
					}).then(annoInfo=>{
						if(annoInfo.statusCode===200){
							tt.setStorage({
							  key: "session_key",
							  data: annoInfo.data.data.session_key
							});
							tt.setStorage({
							  key: "annoInfo",
							  data: annoInfo
							});
							let params = {
								"douyinId": annoInfo.data.data.openid,
								"toutiaoId": annoInfo.data.data.unionid
							}
							tui.tPostAction('/profile/proXxbProfileApi/add', params)
								.then((res) => {
									console.log(`getUserInfo 调365用成功 ${JSON.stringify(res)}`);
							})
						}
						
					})
					
					console.log(`login 调用成功${res.code} ${res.anonymousCode}`);
				},
				fail(res) {
					console.log(`login 调用失败`);
				},
			});
			console.log('App Launch')
		},
		onShow: function() {
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		}
	}
</script>

<style lang="scss">
	@import 'uni.scss';
	@import '@/static/style/app.css';
	@import '@/static/style/uni.css';
</style>
